package cn.laixueit.dao;

import cn.laixueit.domain.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 注解实现crud
 */
public interface IUserDao {

    @Select(value = "select * from user")
    public List<User> findAll();

    @Insert("insert into user(username,birthday,sex,address) values(#{username},#{birthday},#{sex},#{address})")
    @Options(useGeneratedKeys = true)
    public void insert(User user);

    @Delete("delete from user where id =#{id}")
    public void delete(Integer id);

    @Update("update user set username=#{username},sex=#{sex},birthday=#{birthday},address=#{address} where id =#{id}")
    public void update(User user);

    @Select("select * from user where id =#{id}")
    public User findOne(Integer id);

    @Select("select * from user where username like '%${value}%'")
    public List<User> findLikeName(String username);

    @Select("select count(1) from user")
    public Integer count();


}
